<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class Index extends Controller
{
	// public function _initialize()
	// {	
	// 	if(!isset($_SERVER["HTTP_REFERER"])){

	// 	}else if(strpos($_SERVER["HTTP_REFERER"],'bolewang')){
			
	// 	}else{
	// 		$this->error('请求非法');
	// 	}
	// }
    public function index()
    {
    	return $this->fetch();
    }

    public function qqoauth()
    {
        
    }

    public function oauth()
    {
        $id = request()->get('id');
    	$user = model('User');
    	$data=$user->where('password',$id)->find();
    	if(isset($data)){
    		$result = $user->save([
    			'status' => 1
    			],['id'=>$data['id']]);
    		if($result==1){
    			$this->success('激活成功!', 'index');
    		}else{
    			$this->success('激活失败!请联系管理员', 'index');
    		}
    	}
    }

    public function newslist()
    {
    	$list = Db::name('news')->where('status',1)->order('id','asc')->cache(true,5)->paginate(6);
    	return json(['data'=>$list->items(),'currentPage'=>$list->currentPage(),'lastPage'=>$list->lastPage()]);
    }

    public function jobslist()
    {
    	$list = Db::name('jobs')->where('status',1)->order('id','asc')->cache(true,5)->paginate(6);
    	return json(['data'=>$list->items(),'currentPage'=>$list->currentPage(),'lastPage'=>$list->lastPage()]);
    }
}
